package com.dolphin.common.expr;

import com.alibaba.fastjson.JSONPath;
import com.googlecode.aviator.runtime.function.AbstractFunction;
import com.googlecode.aviator.runtime.type.AviatorObject;
import com.googlecode.aviator.runtime.type.AviatorRuntimeJavaType;
import org.apache.commons.lang3.StringUtils;

import java.util.Map;

/**
 * @author shida
 */
public class JSONPathFunction extends AbstractFunction {
    private static final String NAME = "json_path";

    public AviatorObject call(Map<String, Object> env, AviatorObject arg1) {
        String path = (String) arg1.getValue(env);
        if(StringUtils.isNotEmpty(path) == true){
            JSONPath jsonPath = JSONPath.compile(path);
            return AviatorRuntimeJavaType.valueOf(null);
        }
        return AviatorRuntimeJavaType.valueOf(null);
    }

    @Override
    public String getName() {
        return NAME;
    }
}
